import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Redirect, Link } from 'react-router-dom'
import styles from  './style.less'
import withStyle from '../../withStyle'
import Header from '../../components/Header/index.js'
import { getHomeList } from './store/actions.js'
import List from '../../components/List/index.js'

class Home extends Component {
	

	componentDidMount() {
		this.props.doGetHomeList()
	}

	render() {
		return (
			<div>
				<Header staticContext={this.props.staticContext}></Header>
				<div className={styles.home} >
					<List staticContext={this.props.staticContext} articleList={this.props.articleList}></List>
				</div>
				
			</div>
		)
	}

}

const mapState = (state) => ({
	articleList: state.home.articleList
})


const mapDispatch = (dispatch) => ({
	doGetHomeList() {
		dispatch(getHomeList())
	}
})



const HomeOut = connect(mapState, mapDispatch)(withStyle(Home, styles))

HomeOut.loadData = (store) => {
	return store.dispatch(getHomeList())
}

export default HomeOut